﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Customer_Profile.eCard.DBDao;
using KVB.Common;
using System.IO;
using Customer_Profile.Admin;

namespace Customer_Profile.eCard.CardAccount
{
    public partial class ExpenseCardSearch : System.Web.UI.Page
    {
        string strUserName = "";
        string strUserID = "";
        string strEntity = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            Comm.CheckSession(this.Page, "/login.aspx", "usermodel");
            if (Session["usermodel"] != null)
            {
                strUserID = ((UserInfoEntity)Session["usermodel"]).UserLoginId;
                strUserName = ((UserInfoEntity)Session["usermodel"]).UserName;
                strEntity = ((UserInfoEntity)Session["usermodel"]).UserOffice;
            }
            else
            {
                Log.WriteDefaultLog("main_01 Page_Load", "Session is null");
                return;
            }

            string strURL = HttpContext.Current.Request.Url.AbsolutePath;
            bool bok = Comm.ifhasright(strUserID, strURL);
            if (!bok)
            {
                Response.Write("你无权访问此页面");
                Response.End();
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            //1,检查卡号是否存在，
            //2,检查卡号是否已经通过审查。
            //3,卡片是否被锁定。
            string strCardNo = txtCardNo.Text.Trim();
            string strStatus = "";
            string strMessage = "";

            if (strCardNo.Equals(""))
            {
                lblWaring.Text = "卡片号码不能为空！";
            }
            else
            {
                AccountingDao.CardAccountingCheck(strCardNo, out strStatus, out strMessage);
                if (strStatus.Equals("N"))
                {
                    lblWaring.Text = strMessage;
                }
                else
                {
                    Response.Redirect("ExpenseCardAccountingAdd.aspx?card_no=" + strCardNo, false);
                }
            }
        }
    }
}